//
//  UserJubuViewModel.m
//  HiCar
//
//  Created by huachun on 2019/3/4.
//  Copyright © 2019 丁一. All rights reserved.
//

#import "UserJubuViewModel.h"
#import "HiJonesClass.h"
#import "PostJubuVModel.h"

@implementation UserJubuViewModel

+ (UserJubuViewModel *)show:(UIViewController *)supervc dic:(NSDictionary *)dic{
    UserJubuViewModel *viewmdoel = [[UserJubuViewModel alloc] init:supervc dic:dic];
    return viewmdoel;
}

- (instancetype)init:(UIViewController *)supervc dic:(NSDictionary *)dic{
    if (self=[super init]) {
        
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet];
        
        NSDictionary *carlist=[HiJonesClass readLocalFileWithName:@"report"];
        
        [[carlist objectForKey:@"problem"] enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            UIAlertAction *sureAction = [UIAlertAction actionWithTitle:[obj objectForKey:@"name"] style:UIAlertActionStyleDestructive handler:^(UIAlertAction * _Nonnull action) {
                
                NSMutableDictionary *postdic = [[NSMutableDictionary alloc] initWithDictionary:dic];
                [postdic setValue:[obj objectForKey:@"name"] forKey:@"info"];
                PostJubuVModel *viewmodel = [[PostJubuVModel alloc] init:postdic];
                viewmodel = nil;
                
                _selectblock (YES);
            }];
            [alertController addAction:sureAction];
        }];

        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
        [alertController addAction:cancelAction];
        
        [supervc presentViewController:alertController animated:YES completion:nil];
        
        
    }
    return self;
}

@end
